import java.util.Random;
import java.util.Scanner;

public class Question03 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //TODO 添加提示
        //1.用户有5000元
        //2.用户输入大小(0-大,1-小)
        //3.生成三个1-6的随机数作为骰子
        //4.根据点数和 判断大小
        //5.根据点数大小,和用户输入的大小进行比较,
        //  如果一致,用户金额+50
        //  如果不一致, 用户金额 -50
        //6.用户没钱了 让他退出
        //7.循环 2-6
        System.out.println("请输入1开始三骰游戏");
        int e = scanner.nextInt();
        while (e != 1) {
            System.out.println("请输入1游戏开始");
            e = scanner.nextInt();
        }
        System.out.println("请下注");
        int f = scanner.nextInt();
        while (f > 5000 || f <= 0) {
            System.out.println("输入错误请重新输入");
            f = scanner.nextInt();
        }
        System.out.println("请选择大小,0为小,1为大");
        int g = scanner.nextInt();
        while (g < 0 || g > 1) {
            System.out.println("输入错误请重新输入");
            g = scanner.nextInt();
        }
        Random random = new Random();
        int b = random.nextInt(17);
        System.out.println("庄家点数为:" + (b + 2));
        int c = random.nextInt(17);
        System.out.println("你的点数为:" + (c + 2));
        int a = 5000;
        while (a > 0) {
            if (b > c && g == 0) {
                System.out.println("你赢了");
                a = a + f;
            } else if (b < c && g == 1) {
                System.out.println("你赢了");
                a = a + f;
            } else if (b > c && g == 1) {
                System.out.println("你输了");
                a = a - f;
            } else if (b < c && g == 0) {
                System.out.println("你输了");
                a = a - f;
            } else {
                System.out.println("平局");
            }
            System.out.println("金额还有" + a);
            if (a < 1) {
                break;
            }
            System.out.println("请下注");
            f = scanner.nextInt();
            while (f > a || f <= 0) {
                System.out.println("输入错误请重新输入");
                f = scanner.nextInt();
            }
            if (f <= a) {
                System.out.println("请选择大小,0为小,1为大");
                g = scanner.nextInt();
                while (g < 0 || g > 1) {
                    System.out.println("输入错误请重新输入");
                    g = scanner.nextInt();
                }
                b = random.nextInt(17);
                System.out.println("庄家点数为:" + (b + 2));
                c = random.nextInt(17);
                System.out.println("你的点数为:" + (c + 2));
            }
        }
        System.out.println("游戏结束");
    }
}
